package com.harry.controller;

import com.harry.pojo.MedicineRepo;
import com.harry.pojo.ScheduleRecord;
import com.harry.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.util.List;

@RestController
@RequestMapping("/doctor")
public class DoctorController
{
    @Autowired
    DoctorService doctorService;

    @GetMapping("/setSchedule/{open_id}/{start_time}/{capacity}")
    public String setSchedule(@PathVariable int capacity, @PathVariable String open_id, @PathVariable Timestamp start_time)
    {
        return doctorService.setSchedule(open_id, start_time, capacity);
    }

    @GetMapping("/getSchedule/{open_id}")
    public List<ScheduleRecord> getSchedule(@PathVariable String open_id)
    {
        return doctorService.getSchedule(open_id);
    }

    @GetMapping("/getScheduleByDoctorId/{doctor_id}")
    public List<ScheduleRecord> getScheduleByDoctorId(@PathVariable int doctor_id)
    {
        return doctorService.getScheduleByDoctorId(doctor_id);
    }

    @GetMapping("/getMedicineRepo")
    public List<MedicineRepo> getMedicineRepo()
    {
        return doctorService.getMedicineRepo();
    }

    @GetMapping("/addMedicine/{medicine_id}/{amount}")
    public void addMedicine(@PathVariable int amount, @PathVariable int medicine_id)
    {
        doctorService.addMedicine(medicine_id, amount);
    }
}
